class Admin::DepositPreferencesController < AdminController
  def index
    @deposit_preferences = DepositPreference.all.order("created_at DESC").page(params[:page]).per(params[:per])
  end

  def new
    @deposit_preference = DepositPreference.new
  end

  def create
    @deposit_preference = DepositPreference.new deposit_preference_params
    if @deposit_preference.save
      redirect_to admin_deposit_preferences_path, notice: "保存成功！"
    else
      redirect_to admin_deposit_preferences_path, notice: "保存失败！"
    end
  end

  def edit
    @deposit_preference = DepositPreference.find params[:id]
  end

  def update
    @deposit_preference = DepositPreference.find params[:id]
    if @deposit_preference.update deposit_preference_params
      redirect_to admin_deposit_preferences_path, notice: "更新成功！"
    else
      redirect_to admin_deposit_preferences_path, notice: "更新失败！"
    end
  end
  
  def destroy
    @deposit_preference = DepositPreference.find params[:id]
    if @deposit_preference.destroy
      redirect_to admin_deposit_preferences_path, notice: "删除成功."
    else
      redirect_to admin_deposit_preferences_path, notice: "删除失败."
    end
  end

  private

  def deposit_preference_params
    params.require(:deposit_preference).permit(:full_money, :bonus, :published)
  end
end
